package twoD.hofem;
/**
 * ProductFunctionR2ToR
 *  w(x1, x2) = alpha*u(x1)*v(x2)
 * @author Team Malamat
 *
 */

public class ProductFunctionR2ToR implements FunctionR2ToR {

	private double alpha_;
	private FunctionRToR u_;
	private FunctionRToR v_;

	/**
	 * 
	 * @param alpha
	 * @param u
	 * @param v
	 */
	public ProductFunctionR2ToR(double alpha, FunctionRToR u, FunctionRToR v ) {
		alpha_ = alpha;
		u_ = u;
		v_ = v;
	}
	
	/**
	 * Gradient of the ProductFunctionR2toR
	 * [du/dx1, dv/dx2]
	 */
	public double[] gradientAt(double xi1, double xi2) {
		return new double[] {alpha_*u_.derivativeAt(xi1)*v_.valueAt(xi2), alpha_*u_.valueAt(xi1)*v_.derivativeAt(xi2)};
	}
	
	/**
	 * Calculates value of two variable function at specified point (x1,x2)
	 *  w(x1, x2) = alpha*u(x1)v(x2)
	 */
	public double valueAt(double xi1, double xi2) {
		// TODO Auto-generated method stub
		return alpha_*u_.valueAt(xi1)*v_.valueAt(xi2);
	}



}
